package com.qf.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.qf.pojo.resp.BaseResp;
import com.qf.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created with IntelliJ IDEA. User: Administrator Date: 2021/11/10 0010 Time: 17:18 Description: No
 * Description
 */
@RestController
@RequestMapping("/order")
@RefreshScope
public class OrderController {

  @Autowired OrderService orderService;

  @Value("${qf.shop.name}")
  private String name;

@RequestMapping("/getName")
public String getName(){
    return name;
}

  @RequestMapping("/findOrderByUserId")
  @HystrixCommand(fallbackMethod = "findOrderByUserIdError")
  public BaseResp findOrderByUserId(@RequestBody Map map) {

    return orderService.findOrderByUserId(map.get("id"));
  }

  public BaseResp findOrderByUserIdError(@RequestBody Map map) {
    return new BaseResp(0, "接口异常！", null, null);
  }
}
